# UTF-8 文件的读
# f=open("C:/word.txt.txt","r",encoding="UTF-8")
# read readline readlines 每使用一次 指针都会后移 每次都从上一次的地方读取
import time

# content1=f.read() #content1 类型为 str
# print("type content1",type(content1),content1)

# content2=f.readline() #content2 类型为 str 打印有\n             自己有\n   print 也有\n
# print("type content2",type(content2),content2)

# content3=f.readlines() #content3 类型为 list 打印有  '\n'
# print("type content3",type(content3),content3)

# count=content.count("itheima")
# print(count)
# f.close()
# ================================================================================
# # 方法0：
# f=open("C:/word.txt.txt")
# content=f.read()
# count=content.count("itheima")
# print(count)
# ------------------------------------------------------------------
# f=open("C:/word.txt.txt","r",encoding="UTF-8")
# count=0
# # 方法一：
# for line in f:
#     # print("type line ",type(line),line)   #和read.line() 一样
#     line=line.replace("\n","") # replace之后得到新的str
#     # print(type(line))
#     words = line.split(" ") #split ->列表 words
#    # print(words)
#     for word in words:
#         if word=="itheima":
#             count+=1
# print(count)
# f.close()
# # 方法二：
# for line in f:
#     line=line.strip() #strip(去除首尾的空格和换行符) 之后也是新的 line str
#     words=line.split(" ")
#     for word in words:
#         if word=="itheima":
#             count+=1
# print(count)
# f.close()
# ---------------------------------------------------------------------------
# 文件的写
# f=open("C:/word_2024_4_21.txt", "w", encoding="UTF-8")
# f.write("2024_4_21 python xxl")
# f.flush()
# f.close()
# f=open("C:/word_2024_4_21.txt","r",encoding="UTF-8")
# content=f.read()
# print(content)
#-----------------------------------------------------------------------------------
# a
# f=open("C:/word_2024_4_21_test","a",encoding="UTF-8")
# f.write("2024 4 21 学python")
# f.flush()
# f.close()
# ===================================
f1=open("C:/bill.txt","r",encoding="UTF-8")
f2=open("C:/billxxl.txt","w",encoding="UTF-8")
for line in f1:     ##line 是str
    line=line.strip()  ##strip 之后还是str
    print(line.split(","))
    if line.split(",")[4]=="测试":  ##split 后变为list
        continue
    f2.write(line+"\n")  ##写入的东西必须是str 所以line 为str
    f2.write("\n")
f1.close()
f2.close()
